<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>阳光成单系统</title>
		<!--<link rel="stylesheet" href="../css/x-admin.css" media="all">-->
		<link rel="stylesheet" href="../assets/css/layui.css">
		<link rel="stylesheet" href="../assets/css/view.css" /> 

	</head>

	<!--导入核心bootstrap css样式-->
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" />
	<!--导入jQuery-->
	<script src="../js/jquery-3.2.0.min.js" type="text/javascript" charset="utf-8"></script>
	<!--导入核心Bootstrap js-->
	<script src="../js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="../js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
	<script src="../js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../assets/layui-v2.4.5/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="../assets/layui-v2.4.5/layui/css/layui.css"/>
	
	<script>
			$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
				$.ajaxSetup({
					crossDomain: true,
					xhrFields: {
						withCredentials: true
					}
				});
			});
		</script>
	<script type="text/javascript">
		$(function() {
			$.getJSON("http://127.0.0.1:8099/cgrk/findsup", function(data) {
				$.each(data, function(i, d) {
					$("#gys").append("<option value=" + d.sid + ">" + d.supplier_name + "</option>");
				});
			});

			$(function() {
				$("#tab").bootstrapTable({
					url: "http://127.0.0.1:8099/getBatchesOf",
					pagination: true,
					queryParams: queryParams,
					columns: [{
						field: 'batches_of_inventory_id',
						title: '编号',
						align: 'center'
					}, {
						field: 'batches_of_inventory_number',
						title: '制单号',
						align: 'center'
					}, {
						field: 'purchasing_agent_id',
						title: '采购人',
						align: 'center'
					}, {
						field: 'batches_of_inventory_total_money',
						title: '采购金额',
						align: 'center'
					}, {
						field: 'batches_of_inventory_date',
						title: '采购日期',
						align: 'center'
					}, {
						field: 'batches_of_inventory_verifier',
						title: '审核人',
						align: 'center'
					}, {
						field: 'batches_of_inventory_verifier_date',
						title: '审核日期',
						align: 'center'
					}, {
						field: 'supplier_name',
						title: '供应商',
						align: 'center'
					}, {
						field: 'batches_of_inventory_status',
						title: '状态',
						align: 'center',
					}, {
						title: '操作',
						align: 'center',
						formatter: function(value, row, index) {
							return "<button class='btn btn-primary'  onclick='ck(" + row.batches_of_inventory_id + ",\"" + row.batches_of_inventory_status + "\")'>查看</button>     <button class='btn btn-info'  onclick='zcrk(" + row.batches_of_inventory_id + ")'>再次入库</button>   <button class='btn btn-danger'  onclick='del(" + row.batches_of_inventory_id + ")'>删除</button>"
						}
					}]
				})

			})
			$("#sel").click(function() {
				$("#tab").bootstrapTable("refresh");
			})

		});

		function queryParams() {
			return {
				'batches_of_inventory_number': $("#zdh").val(),
				'batches_of_inventory_status': $("#shzt").val(),
				'supplier_id': $("#gys").val(),
				'batches_of_inventory_date': $("#cgrq").val(),
				'batches_of_inventory_dates': $("#cgrq2").val()
			}
		}

		function ck(batchesOfInventoryId, batchesOfInventoryStatus) {
			//			  	window.location.href ="audit-list-show.html?batchesOfInventoryStatus="+  encodeURI(encodeURI(batchesOfInventoryStatus))+""
			var r;
			if(batchesOfInventoryStatus == "已审核") {
				r = 1
			} else if(batchesOfInventoryStatus == "未审核") {
				r = 2
			}
			window.location = 'audit-list-show.html?' + batchesOfInventoryId + '&' + r
		}

		function zcrk(batchesOfInventoryId) {
			window.location = 'operaterule_two.html?' + batchesOfInventoryId
		}

		function del(batches_of_inventory_id) {

			$.ajax({
				type: "post",
				url: "http://127.0.0.1:8099/delBatchesOfs",
				data: "batchesOfInventoryId=" + batches_of_inventory_id,
				success: function(data) {
					$("#tab").bootstrapTable("refresh");
				}
			});

		}
	</script>

	<body>
		<div class="x-nav">
			<span class="layui-breadcrumb">
              <a><cite>首页</cite></a>	<a><cite>入库审核</cite></a>	<a><cite>列表</cite></a>
            </span>
		</div>
		<div class="x-body">
			<form class="form-inline">
				<div class="form-group">
					<label for="zdh">制单号</label>
					<input type="text" class="form-control" id="zdh" placeholder="请输入制单号">
				</div>
				<div class="form-group">
					<label for="shzt">审核状态</label>
					<!--<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">-->
					<select id="shzt" class="form-control">
						<option value="0">全部</option>
						<option value="1">已审核</option>
						<option value="2">未审核</option>
					</select>
				</div>
				<div class="form-group">
					<label for="gys">供应商</label>
					<!--<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">-->
					<select id="gys" class="form-control">
						<option value="0">全部</option>
					</select>
				</div>
				<div class="form-group">
					<label for="cgrq">采购日期</label>
					<input type="text" class="form-control" id="cgrq">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="text" class="form-control" id="cgrq2">
				</div>

				<button type="button" class="btn btn-default" id="sel">查询</button>
				<div class="form-group" style="text-align: right; width: 250px;" >
								<a  class="layui-btn layui-btn-small layui-btn-radius layui-icon layui-icon-refresh" href="javascript:location.replace(location.href);" title="刷新"></a>

					
				</div>
			</form>
			
			<br />

			<table id="tab" class="table text-center">

			</table>
			
			

		</div>
		
	</body>

</html>